<?php
/**
 * java api包  用于多线程生成静态文件
 * Enter description here ...
 * @author Administrator
 *
 */
class JavaController extends NodeController
{
    
    /**
     * java包的调用接口
     * Enter description here ...
     */
    public function setProcess()
    {
        if ($_POST['type'] == '-c') {
            @exec(`export LANG='en_US.UTF-8';java -jar batch.jar 3 -c > p.txt &`);
        } else {
            @exec(`export LANG='en_US.UTF-8';java -jar batch.jar 3 -n > p.txt &`);
        }
        
        echo "正在执行";
    }
    /*java接口*/
    public function batchall()
    {
        if ($_POST['process']) {
            $filename = getcwd() . "/p.txt";
            $handle = fopen($filename, "r");
            $jd = 0;
            while ($process = fgets($handle)) {
                $jd = $process;
            }
            
            //  $process = rand(10, 100);
            $this->sendNotice("", trim($jd), true);
            exit();
        }
        
        $this->view()->display("file:news/batch_all.tpl");
    }
}